
"""5.4 视图高级技巧（装饰器与中间件）"""
import time


def access_log(view_func):
    def wrapper(request,*args,**kwargs):
        #实现的效果：[访问日志] 时间：2025-04-22 15:00:00，方法：GET，路径：/home/
        print(f"[访问日志] 时间：{time.strftime('%Y-%m-%d %H:%M:%S')}，方法：{request.method}，路径：{request.path}")
        #打印出http状态
        reponse = view_func(request,*args,**kwargs)
        print(f"[访问日志] 状态：{reponse.status_code}")
        return reponse
    return wrapper


